import 'package:flutter/material.dart';
import 'package:flutter_animation/widget/ball/runball-widget.dart';
import 'package:flutter_animation/widget/explode/explode_page.dart';

import 'package:flutter_animation/widget/home/home_page.dart';
import 'package:flutter_animation/widget/mole/mole_page.dart';
import 'package:flutter_animation/widget/mypage/my_page.dart';
import 'package:flutter_animation/widget/particle/particle_page.dart';
import 'package:flutter_animation/widget/wave/wave_page.dart';
import 'package:flutter_animation/widget/flip/flip_widget_page.dart';

final Map<String, Widget Function(dynamic)> myRoutes = {
  '/': (context) => MyHomePage(),
  '/particle-page': (context, {arguments}) =>
      ParticlePage(arguments: arguments),
  '/wave-page': (context) => WavePage(),
  '/mole-page': (context) => MolePage(),
  '/explode-page': (context) => ExplodePage(),
  '/flip_widget_page': (context) => FlipWidgetPage(),
  '/run_ball_widget_page': (context) => RunBall(),
  '/my_page': (context) => MyPage(),
};

final Function generateRoute = (RouteSettings settings) {
  final String routerName = settings.name;
  final Function pageContentPage = myRoutes[routerName];

  // try
  Route routePage;
  if (settings.arguments != null) {
    routePage = MaterialPageRoute(
        builder: (context) =>
            pageContentPage(context, arguments: settings.arguments));
  } else {
    routePage =
        MaterialPageRoute(builder: (context) => pageContentPage(context));
  }

  return routePage;
};
